﻿using System;

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;

namespace ZoeEngine.Services.Input
{
    public interface IInputService : IGameComponent
    {
        void ClearListeners();

        event EventHandler<KeyboardEventArgs> KeyboardKeyUp;
        event EventHandler<KeyboardEventArgs> KeyboardKeyHeld;
        event EventHandler<KeyboardEventArgs> KeyboardKeyDown;

        event EventHandler<MouseEventArgs> MouseButtonPress;
        event EventHandler<MouseEventArgs> MouseButtonHeld;
        event EventHandler<MouseEventArgs> MouseButtonRelease;
        event EventHandler<MouseEventArgs> MouseMotion;
    }

    public class KeyboardEventArgs : EventArgs
    {
        private Keys _activeKey;
        private Keys _modifierKey;
        private GameTime _deltaTime;

        public KeyboardEventArgs(Keys activeKey, Keys modifierKey, GameTime deltaTime)
        {
            this._activeKey = activeKey;
            this._modifierKey = modifierKey;
            this._deltaTime = deltaTime;
        }

        public Keys ActiveKey
        {
            get
            {
                return _activeKey;
            }
        }
        public Keys ModifierKey
        {
            get
            {
                return _modifierKey;
            }
        }
        public GameTime DeltaTime
        {
            get
            {
                return _deltaTime;
            }
        }
    }
    public class MouseEventArgs : EventArgs
    {
        private MouseButton _buttons;
        private GameTime _deltaTime;
        private int _mouseX;
        private int _mouseY;

        public MouseEventArgs(int mouseX, int mouseY, MouseButton buttons, GameTime deltaTime)
        {
            this._mouseX = mouseX;
            this._mouseY = mouseY;
            this._buttons = buttons;
            this._deltaTime = deltaTime;
        }

        public MouseButton Buttons
        {
            get
            {
                return _buttons;
            }
        }
        public GameTime DeltaTime
        {
            get
            {
                return _deltaTime;
            }
        }
    }

    [Flags]
    public enum MouseButton
    {
        Left = 0x01,
        Middle = 0x02,
        Right = 0x04,
        None = 0x00
    }
}
